﻿/*------------------------------------------------------------
 * Author : Tharinduni Udugamasuriya
 * FinCon dll for Handeling DB 
 * SpCaller : Stored Procedure Management
 -----------------------------------------------------------*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DSPL.DataAccess
{
    public class SpCaller
    {
        public string FcnName { get; set; }
        public string SpName { get; set; }
        public ParameterWithValue[] SpParamValues { get; set; }

        //public SpCaller(string spName, ParameterWithValue[] parmSet)
        //{
        //    SpName = spName;
        //    SpParamValues = parmSet;
        //}

        //public SpCaller(string fcnName, ParameterWithValue[] parmSet, bool isFcn)
        //{
        //    if (isFcn)
        //    {
        //        FcnName = fcnName;
        //        SpParamValues = parmSet;
        //    }
        //    else
        //    {
        //        SpName = fcnName;
        //        SpParamValues = parmSet;
        //    }
            
        //}

        public object GetValue(string name)
        {
            
            foreach (ParameterWithValue item in SpParamValues)
            {
                if (item.SpParameter.ParameterName.Equals(name))
                {
                    return item.GetValue();
                }
            }
            throw new Exception("Parameter " + name + ", does not exist");
        }
    }
}
